package pCloud.message;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * This contains the query
 *
 */
public class PolicyQueryReply implements Serializable{

	ArrayList<PolicyInfo> policyInfos;	
	public PolicyQueryReply() {				
		this.policyInfos = new ArrayList<PolicyInfo>();
	}

	public void addPolicyInfo(int index, String id){
		policyInfos.add(new PolicyInfo(index, id));
	}
	
	public ArrayList<PolicyInfo> getPolicyInfos(){
		return this.policyInfos;
	}
	
	public String toString(){
		if (this.policyInfos.size()==0)
			return "No policy found at the server";
		String reply = "PolicyId \t Policy index:\n";
		PolicyInfo pi = null;
		for (int i=0; i<this.policyInfos.size(); i++){
			pi = this.policyInfos.get(i);
			reply+=pi.getId()+" \t "+pi.getIndex()+"\n";
		}
		return reply;
	}
}

class PolicyInfo implements Serializable{
	int index;
	public int getIndex() {
		return index;
	}

	public String getId() {
		return id;
	}

	String id;
	
	public PolicyInfo(int index, String id){
		this.id = id;
		this.index = index;
	}
	
	
}
